#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    int equalSubstring(string s, string t, int maxCost) {
        //使用滑动窗口求解
        int left = 0;
        int right = 0;
        int count = 0; 
        int result = 0;
        int size = s.size();
        while(right<size){
            count += abs(t[right]-s[right]);
            if(count>maxCost){
                result = max(result,right-left);
                count -= abs(t[left]-s[left]);
                ++left;
            }
            ++right;
        }
        result = max(result,right-left);
        return result;   
    }
};


int main(){
    Solution S;
    cout<<S.equalSubstring("abcd","bcdf",3)<<endl;
}